<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>dom事件练习</title>
    <style>
        .input-box {
            display: block;
        }
    </style>
</head>
<body>
    <div class="input-box">
        <input type="text" placeholder="focus it" id="focus"/>
        <button id="button">focus it</button>
    </div>
    <div class="input-box">
        <input type="text" placeholder="plain input" />
    </div>
    <a href="#">link</a>

    <script>
        var focus = document.getElementById('focus');
        window.onload = function(){
            focus.focus();
        };

        document.getElementById('button').onclick = function (e) {
//            focus.focus();
//            document.getElementsByTagName('a')[0].focus();
            e.target.focus();
        };

    </script>
</body>
</html>